Optional Motifs.f

{ TO DO
   Add motif-sorting
   Opaque/transparent pass
}

Requires SORA\Blocks
Requires SORA\Transformations
Requires Linked-lists

Only Forth Definitions


Block-type: [Motif]
-? /Node blk property node
-? /Transform blk property transform
   cell blk property w
-? cell blk property h
   cell blk property d
   cell blk property vx
   cell blk property vy
   cell blk property vz
   cell blk property slot
   cell blk property slotpool
   cell blk property 'show

:macro pos   transform ->pos ;
:macro angle   transform ->rotation ;
:macro scale  transform ->scale ;
:macro x   transform ->pos ->x ;
:macro y   transform ->pos ->y ;
:macro z   transform ->pos ->z ;
:macro pan   transform ->rotation ->x ;
:macro tilt   transform ->rotation ->y ;
:macro rotation   transform ->rotation ->z ;
:macro sx   transform ->scale ->x ;
:macro sy   transform ->scale ->y ;
:macro sz   transform ->scale ->z ;
:macro color   transform ->color ;

:macro ->transform   /node + ;

:macro !alpha   color 3 + c! ;
:macro @alpha   color 3 + c@ ;


: init-me   ( <<me>> -- )
   $FFFFFFFF color !
   255 !alpha
   1.0 1.0 1.0 scale 3v! ;


:[] show:[   ( <<me>> xt -- ) ( <<me>> -- )
   'show ! ;

:macro me         blk @ ;
:macro @parent    node ->parent @ ;
:macro children?  node ->first @ ;
:macro add        add-child ;
:macro remove     remove-node ;

\ name is historical
:[] each:[  ( parent-motif xt -- ) ( <<me>> -- )
   swap
   ->first @
   begin dup while
      dup ->next @ >q << dup execute >> q>
   repeat 2drop ;

: show   << 'show @ execute >> ;

: Motif:
   create /block /allot
   lastbody << init-me >> ;
